package org.example.springioc.Controller;

import org.example.springioc.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * 构造方法注入
 */

@Controller
public class UserController2 {
    //注入构造方法
    private UserService userService;

    @Autowired
    public UserController2(UserService userService) {
        this.userService = userService;
    }

    public void hello() {
        System.out.println("hello userController2");
        userService.hello();
    }
}
